<template>
	<view>
		<view class="flex a-t box">
			<image :src="vuex_user.avatar" style="width: 60px;border-radius: 50%;margin-right: 10px;" mode="widthFix"></image>
			<view style="line-height: 30px;">
				<view class="f16 fb">{{ vuex_user.nickname }}</view>
				<view>平均月经周期{{vuex_avg}}天</view>
			</view>
			<view @click="gourl(1)" style="border: #fa1e8a solid 1px;border-radius: 30px;height: 30px;padding: 0 20px;line-height: 30px;color: #fa1e8a;margin-left: auto;">
				设置
			</view>
		</view>
		<!-- <view style="background: #eee;" class="box f12">2022年姨妈期</view> -->
		<u-cell-group><u-cell-item v-for="item in list" @click="gourl(item)" :title="title(item)"></u-cell-item></u-cell-group>
	</view>
</template>

<script>
export default {
	computed: {
		title() {
			return item => {
				return item.start_date + '开始' + (item.end_date ? item.end_date + '结束' : '还未结束') + (item.total ? '共' + item.total + '天' : '');
			};
		}
	},
	data() {
		return {
			list: []
		};
	},
	onLoad() {
		uni.setNavigationBarColor({
			frontColor: '#000000',
			backgroundColor: '#ffffff'
		});
	},
	onShow() {
		this.getList();
	},
	methods: {
		getList() {
			this.$u.api.auntList().then(res => {
				this.list = res;
			});
		},
		gourl(item) {
			// uni.navigateTo({
			// 	url:'./list'
			// })
			if(item==1){
				return uni.navigateTo({
					url:'./list'
				})
			}
			this.$u.route({
				url: '/pages/lishi/lishi',
				params: {
					item: item!=1 ? encodeURIComponent(JSON.stringify(item)) : 1
				}
			});
		}
	}
};
</script>

<style>
page {
	background: #fff;
}
</style>
